package com.study.homework;

public class ArrayStack {

    private final int[] ints;
    private int topIndex;

    public ArrayStack(int len) {
        ints = new int[len];
        topIndex = 0;
    }

    public void push(int a) {
        if (topIndex > ints.length - 1) {
            throw new StackOverflowError();
        }
        ints[topIndex++] = a;
    }

    public int pop() {
        if (topIndex < 0) {
            return -1;
        }
        return ints[--topIndex];
    }
}
